package praktikumid.p06_k;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class ParseDate {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Locale.setDefault(Locale.US);
		String dateString = "Tue, 09 Oct 2012 09:45:01 UT";
		/*
		 * Mon, xxxx
		 * Tue
		 * Wed
		 * Thu
		 * Fri
		 * Sat
		 * Sun
		 */
		// 2012-10-09 09:45:01
		/*
		 * SimpleDateFormat sdf <- formaat
		 * 
		 * sdf: date -> string
		 * sdf: string -> date
		 * 
		 * Tue, 09 Oct 2012 09:45:01 UT ->
		 * -> Date ->
		 * -> 2012-10-09 09:45:01
		 */
		// NB! timezone is not correct
		// doesn't matter for Feed exercise
		SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'UT'");
		try {
			Date date = sdf.parse(dateString);
			System.out.println(date);
			
			System.out.println(date.getTime());
			
			SimpleDateFormat sdfout = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			String newDateString = sdfout.format(date);
			System.out.println(newDateString);
			
			//
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		

	}

}
